package com.czl.module_storehouse.adapter;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.czl.module_storehouse.R;
import com.czl.module_storehouse.bean.AllocateBean;
import com.lihang.ShadowLayout;

import java.util.List;

/**
 * @author xubin
 */
public class AllocateAdapter extends BaseQuickAdapter<AllocateBean, BaseViewHolder> {

    public AllocateAdapter(int layoutResId, @Nullable List<AllocateBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, AllocateBean item) {
        helper.setText(R.id.tv_title, item.getMoveName())
                .setText(R.id.tv_date, item.getGmtCreate())
                .setText(R.id.tv_code, "调拨单：" + (item.getMoveCode() == null ? "" : item.getMoveCode()))
                .setText(R.id.tv_out_storage, "调出仓库：" + (item.getMoveStorehouseName() == null ? "" : item.getMoveStorehouseName()))
                .setText(R.id.tv_in_storage, "调入仓库：" + (item.getInStorehouseName() == null ? "" : item.getInStorehouseName()));
        helper.getView(R.id.cl_root)
                .setOnClickListener(v -> {
                    if (getOnItemChildClickListener() != null) {
                        getOnItemChildClickListener().onItemChildClick(AllocateAdapter.this, v, helper.getLayoutPosition());
                    }
                });
        ShadowLayout shadowLayout = helper.getView(R.id.shadowLayout);
        shadowLayout.setShadowHiddenBottom(helper.getLayoutPosition() != getDefItemCount() - 1);
    }
}
